import { Controller, Get, Post, Body, Param, Delete } from '@nestjs/common';
import { TalkService } from './talk.service';
import { RoomEntity } from './entities/room.entity';

@Controller('talk')
export class TalkController {
  constructor(private readonly talkService: TalkService) {}

  @Post('createRoom')
  create(@Body() room: RoomEntity) {
    return this.talkService.create(room);
  }

  @Delete('deleteRoom/:id')
  remove(@Param('id') id: number) {
    return this.talkService.remove(id);
  }

  @Post('updateRoom')
  update(@Body() room: RoomEntity) {
    return this.talkService.update(room);
  }

  @Get('talkList/:roomName')
  getTalkByRoomName(@Param('roomName') roomName: string) {
    return this.talkService.getTalkByRoomName(roomName);
  }

  @Get('roomList/:page/:limit')
  getRoomList(@Param('page') page, @Param('limit') limit) {
    return this.talkService.getRoomList(page, limit);
  }

  @Get('onlineUserList/:roomName')
  getOnlineUserList(@Param('roomName') roomName) {
    return this.talkService.getOnlineUserList(roomName);
  }
}
